﻿using System;
using System.Windows;
using EventAggregator;

namespace EAWpfSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Subscribe(EventId.Default.AppStartup, HandleAppStartup);
            this.Subscribe(EventId.Default.Dispatch, HandleDispatch);
        }

        private void HandleDispatch(EventMessage eventMessage)
        {
            Dispatcher.Invoke(eventMessage.GetValue<Action>("Dispatch"));
        }

        private void HandleAppStartup(EventMessage eventMessage)
        {
            Show();
        }
    }
}